********************************************************************************
* Replication Do File for Appendix:
* Benjamin Smith and David Waldner (2020) 
* "Endogenous Sovereignty and Survivorship Bias in Comparative Politics"

* Data generated using Stata 16 

********************************************************************************

use "Smith.Waldner.2020.Replication.dta", clear

********************************************************************************
* TABLE A1. Logit Models on the Impact of Oil Wealth on 
* Authoritarian Breakdown with CGV Autocratic Spell 
********************************************************************************

* Model a1 
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
lnrentlevnew i.post1980 aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog ///
robust cluster (country) 
eststo ma1

* Model a2
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
c.lnrentlevnew i.post1980 c.lnrentlevnew#i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 
eststo ma2

* Model a3
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
log_oilgas i.post1980 aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog ///
robust cluster (country) 
eststo ma3

* Model a4
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
c.log_oilgas i.post1980 c.log_oilgas#i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 
eststo ma4

* Model a5
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
log_rentlevnew_counter i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 
eststo ma5

* Model a6
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
c.log_rentlevnew_counter i.post1980 c.log_rentlevnew_counter#i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 
eststo ma6

* Model a7
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
log_oilgas_counter i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 
eststo ma7

* Model a8
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
c.log_oilgas_counter i.post1980 c.log_oilgas_counter#i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 
eststo ma8

estout ma1 ma2 ma3 ma4 ma5 ma6 ma7 ma8 using smith.walder.a.table1.xls, replace ///
cells(b(star fmt(3)) se(par(`"="("'`")""'))) stats(N aic bic) /// 
starlevels(* 0.10 ** 0.05 *** 0.01) 


********************************************************************************
* FIGURE A1. Predicted Probabilities of Authoritarian Breakdown as 
* a Function of Rent Leverage (Model a1) and Oil & Gas Income (Model a3) 
* with CGv Autocratic Spell
********************************************************************************

* Model a1
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
lnrentlevnew i.post1980 aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog ///
robust cluster (country) 

margins, at(lnrentlevnew = (-5(1)4)) 
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ylabel(0(0.01)0.1) ///
xtitle(Logged Rent Leverage) xlabel(-5(1)4)

* Model a3
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
log_oilgas i.post1980 aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog ///
robust cluster (country) 

margins, at(log_oilgas = (-7(1)11)) 
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ylabel(0(.01)0.1) ///
xtitle(Logged Oil&Gas Income) xlabel(-7(1)11)


********************************************************************************
* FIGURE A2. Predicted Probabilities of Authoritarian Breakdown 
* by Counterfactual Rent Leverage (Model a5) and Oil & Gas Income (Model a7) 
* with CGV Autocratic Spell
********************************************************************************

* Model a5
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
log_rentlevnew_counter i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 

margins, at(log_rentlevnew_counter = (-5(1)4)) 
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ///
ylabel(0(0.01)0.1) xtitle(Logged Rent Leverage) xlabel(-5(1)4)

* Model a7
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
log_oilgas_counter i.post1980 ///
aut_duration_cgv_sp1-aut_duration_cgv_sp2, nolog robust cluster (country) 

margins, at(log_oilgas_counter = (-7(1)11))  
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ylabel(0(.01)0.1) ///
xtitle(Logged Oil&Gas Income) xlabel(-7(1)11)


********************************************************************************
* TABLE A2. Survival Models on the Impact of Oil and Gas Revenues on 
* Authoritarian Breakdown with CGV Autocratic Spell
********************************************************************************

stset dura_2, failure(aut_spell_event_cgv) id(ccode)

* Model a9
stcox cgdpo mad_growth neighbor_cg_democracy lnrentlevnew i.post1980, nolog ///
nohr robust efron cluster(ccode) strata(past_aut_spell_cgv) 
eststo ma9

* Model a10
stcox cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew i.post1980 ///
c.lnrentlevnew#i.post1980, nolog nohr robust efron cluster(ccode) ///
strata(past_aut_spell_cgv) 
eststo ma10

* Model a11
stcox cgdpo mad_growth neighbor_cg_democracy log_oilgas i.post1980, nolog ///
nohr efron robust cluster(ccode) strata(past_aut_spell_cgv) 
eststo ma11

* Model a12
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas i.post1980 ///
c.log_oilgas#i.post1980, nolog nohr efron robust cluster(ccode) ///
strata(past_aut_spell_cgv) 
eststo ma12

* Model a13
stcox cgdpo mad_growth neighbor_cg_democracy log_rentlevnew_counter ///
i.post1980, nolog nohr robust efron cluster(ccode) strata(past_aut_spell_cgv) 
eststo ma13

* Model a14
stcox cgdpo mad_growth neighbor_cg_democracy c.log_rentlevnew_counter ///
i.post1980 c.log_rentlevnew_counter#i.post1980, nolog nohr robust efron ///
cluster(ccode) strata(past_aut_spell_cgv) 
eststo ma14

* Model a15
stcox cgdpo mad_growth neighbor_cg_democracy log_oilgas_counter ///
i.post1980, nolog nohr efron robust cluster(ccode) strata(past_aut_spell_cgv) 
eststo ma15

* Model a16
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas_counter i.post1980 ///
c.log_oilgas_counter#i.post1980, nolog nohr efron robust cluster(ccode) ///
strata(past_aut_spell_cgv) 
eststo ma16

estout ma9 ma10 ma11 ma12 ma13 ma14 ma15 ma16 using smith.walder.a.table2.xls, replace ///
cells(b(star fmt(3)) se(par(`"="("'`")""'))) stats(N aic bic) /// 
starlevels(* 0.10 ** 0.05 *** 0.01) 


********************************************************************************
* FIGURE A3. Predicted Survival Probabilities of Authoritarian Regimes 
* by Rent Leverage (Model a9) and Oil & Gas Income (Model a11) 
* in 1955-2010 with CGV Autocratic Spell
********************************************************************************

* Model a9
stcox cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew i.post1980, nolog ///
nohr robust efron cluster(ccode) basesurv(base9)

gen sd9 = base9^exp(_b[lnrentlevnew]*(-2.4756073))

line base9 sd9 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Rent Leverage Mean+2SD"))

* Model a11
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas i.post1980, nolog ///
nohr efron robust cluster(ccode) basesurv(base11)

gen sd11 = base11^exp(_b[log_oilgas]*(11.427869))

line base11 sd11 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Oil&Gas Income Mean+2SD"))


********************************************************************************
* FIGURE A4. Predicted Survival Probabilities of Authoritarian Regimes 
* by Counterfactual Rent Leverage (Model a13) and Oil & Gas Income (Model a15)
* in 1955-2010 with CGV Autocratic Spell
********************************************************************************

* Model a13
stcox cgdpo mad_growth neighbor_cg_democracy c.log_rentlevnew_counter ///
i.post1980, nolog nohr robust efron cluster(ccode) basesurv(base13)

gen sd13 = base13^exp(_b[log_rentlevnew_counter]*(-.52681921))

line base13 sd13 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Rent Leverage Counterfactual Mean+2SD") size(small))

* Model a15
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas_counter ///
i.post1980, nolog nohr efron robust cluster(ccode) basesurv(base15)

gen sd15 = base15^exp(_b[log_oilgas_counter]*(10.758885))

line base15 sd15 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Oil & Gas Income Counterfactual Mean+2SD") size(small))


********************************************************************************
* TABLE A3. Logit Models on the Impact of Oil Wealth on 
* Authoritarian Breakdown with Geddes Autocratic Spell
********************************************************************************

* Model a17
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew ///
i.post1980 geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma17

* Model a18
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew ///
i.post1980 c.lnrentlevnew#i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma18

* Model a19
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.log_oilgas ///
i.post1980 geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma19

* Model a20
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.log_oilgas ///
i.post1980 c.log_oilgas#i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma20

* Model a21
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_rentlevnew_counter i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma21

* Model a22
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_rentlevnew_counter i.post1980 c.log_rentlevnew_counter#i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma22

* Model a23
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_oilgas_counter i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma23

* Model a24
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_oilgas_counter i.post1980 c.log_oilgas_counter#i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 
eststo ma24

estout ma17 ma18 ma19 ma20 ma21 ma22 ma23 ma24 using smith.walder.a.table3.xls, replace ///
cells(b(star fmt(3)) se(par(`"="("'`")""'))) stats(N aic bic) /// 
starlevels(* 0.10 ** 0.05 *** 0.01) 


********************************************************************************
* FIGURE A5. Predicted Probabilities of Authoritarian Breakdown 
* as a Function of Rent Leverage (Model a17) and Oil & Gas Income (Model a19) 
* with Geddes Autocratic Spell
********************************************************************************

* Model a17
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew ///
i.post1980 geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 

margins, at(lnrentlevnew = (-5(1)4)) atmeans 
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ylabel(0(0.01)0.1) ///
xtitle(Logged Rent Leverage) xlabel(-5(1)4)

* Model a19
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.log_oilgas ///
i.post1980 geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 

margins, at(log_oilgas = (-7(1)11)) atmeans 
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ylabel(0(.01)0.1) ///
xtitle(Logged Oil&Gas Income) xlabel(-7(1)11)


********************************************************************************
* FIGURE A6. Predicted Probabilities of Authoritarian Breakdown 
* by Counterfactual Rent Leverage (Model a21) and Oil & Gas Income (Model a23) 
* with Geddes Autocratic Spell
********************************************************************************

* Model a21
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_rentlevnew_counter i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 

margins, at(log_rentlevnew_counter = (-5(1)4)) atmeans 
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ///
ylabel(0(0.01)0.1) xtitle(Logged Rent Leverage) xlabel(-5(1)4)

* Model a23
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_oilgas_counter i.post1980 ///
geddes_duration_sp1-geddes_duration_sp4, nolog robust cluster (country) 

margins, at(log_oilgas_counter = (-7(1)11)) atmeans 
marginsplot, ytitle(Pr(Authoritarian Breakdown)) ylabel(0(.01)0.1) ///
xtitle(Logged Oil&Gas Income) xlabel(-7(1)11)


********************************************************************************
* TABLE A4. Logit Models on the Impact of Oil Wealth on Authoritarian Breakdown 
* with Geddes Autocratic Spell with Cubic Polynomials
********************************************************************************

* Model a25 
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew i.post1980 /// 
geddes_duration geddes_duration2 geddes_duration3, nolog robust cluster (country) 
eststo ma25

* Model a26
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew i.post1980 /// 
c.lnrentlevnew#i.post1980 geddes_duration geddes_duration2 geddes_duration3, nolog ///
robust cluster (country) 
eststo ma26

* Model a27
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.log_oilgas i.post1980 ///
geddes_duration geddes_duration2 geddes_duration3, nolog robust cluster (country) 
eststo ma27

* Model a28
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.log_oilgas i.post1980 ///
c.log_oilgas#i.post1980 geddes_duration geddes_duration2 geddes_duration3, nolog ///
robust cluster (country) 
eststo ma28

* Model a29
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.log_rentlevnew_counter ///
i.post1980 geddes_duration geddes_duration2 geddes_duration3, nolog robust ///
cluster (country) 
eststo ma29

* Model a30
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_rentlevnew_counter i.post1980 c.log_rentlevnew_counter#i.post1980 ///
geddes_duration geddes_duration2 geddes_duration3, nolog robust cluster (country) 
eststo ma30

* Model a31
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy c.log_oilgas_counter ///
i.post1980 geddes_duration geddes_duration2 geddes_duration3, nolog robust ///
cluster (country) 
eststo ma31

* Model a32
logit geddes_fail cgdpo mad_growth neighbor_cg_democracy ///
c.log_oilgas_counter i.post1980 c.log_oilgas_counter#i.post1980 ///
geddes_duration geddes_duration2 geddes_duration3, nolog robust cluster (country) 
eststo ma32

estout ma25 ma26 ma27 ma28 ma29 ma30 ma31 ma32 using smith.walder.a.table4.xls, replace ///
cells(b(star fmt(3)) se(par(`"="("'`")""'))) stats(N aic bic) /// 
starlevels(* 0.10 ** 0.05 *** 0.01) 


********************************************************************************
* TABLE A5. Logit Models on the Impact of Oil Wealth on Authoritarian Breakdown 
* with CGV Autocratic Spell with Cubic Polynomials
********************************************************************************

* Model a33
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew ///
i.post1980 aut_duration_cgv aut_duration_cgv2 aut_duration_cgv3, nolog robust ///
cluster (country) 
eststo ma33

* Model a34
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
c.lnrentlevnew i.post1980 c.lnrentlevnew#i.post1980 ///
aut_duration_cgv aut_duration_cgv2 aut_duration_cgv3, nolog robust cluster (country) 
eststo ma34

* Model a35
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
c.log_oilgas i.post1980 aut_duration_cgv aut_duration_cgv2 ///
aut_duration_cgv3, nolog robust cluster (country) 
eststo ma35

* Model a36
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
c.log_oilgas i.post1980 c.log_oilgas#i.post1980 ///
aut_duration_cgv aut_duration_cgv2 aut_duration_cgv3, nolog robust cluster (country) 
eststo ma36

* Model a37
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
c.log_rentlevnew_counter i.post1980 aut_duration_cgv aut_duration_cgv2 ///
aut_duration_cgv3, nolog robust cluster (country) 
eststo ma37

* Model a38
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy ///
c.log_rentlevnew_counter i.post1980 c.log_rentlevnew_counter#i.post1980 ///
aut_duration_cgv aut_duration_cgv2 aut_duration_cgv3, nolog robust cluster (country) 
eststo ma38

* Model a39
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
c.log_oilgas_counter i.post1980 aut_duration_cgv aut_duration_cgv2 ///
aut_duration_cgv3, nolog robust cluster (country) 
eststo ma39

* Model a40
logit aut_spell_event_cgv cgdpo mad_growth neighbor_cg_democracy /// 
c.log_oilgas_counter i.post1980 c.log_oilgas_counter#i.post1980 ///
aut_duration_cgv aut_duration_cgv2 aut_duration_cgv3, nolog robust cluster (country) 
eststo ma40

estout ma33 ma34 ma35 ma36 ma37 ma38 ma39 ma40 using smith.walder.a.table5.xls, replace ///
cells(b(star fmt(3)) se(par(`"="("'`")""'))) stats(N aic bic) /// 
starlevels(* 0.10 ** 0.05 *** 0.01) 
